<?php
/**
 * Created by PhpStorm.
 * User: MSQ
 * Date: 2021/9/27
 * Time: 16:54
 */

namespace App\Handler\WebSocket;


use App\Model\Baiyou\BaseProject;
use App\Utils\WebSocketMessage;

class ProjectListHandler extends BaseHandler
{
    /**
     * 获取白友项目列表 {"msgType":"projectList","checkType":2}
     * @return string
     */
    public function handler(): string
    {
        $projectList = BaseProject::create()
            ->field(['id', 'name'])
            ->where(['status' => BaseProject::STATUS_ENABLE])
            ->order('sort', 'asc')
            ->order('id', 'asc')
            ->all();

        $data = WebSocketMessage::getMessage(WebSocketMessage::ProjectListRes, $projectList);
        return $data;
    }
}
